package com.rice.commonsdk;

import com.rice.commonsdk.properties.ExecutorProperties;
import com.rice.commonsdk.template.FixedExecutorTemplate;
import com.rice.commonsdk.template.ValidateTemplate;
import jakarta.annotation.Resource;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 项目配置类
 * @author 米饭好好吃
 */
@AutoConfiguration
@EnableConfigurationProperties({ExecutorProperties.class})
public class CommonConfig {
    @Resource
    private ExecutorProperties executorProperties;

    @Bean
    public FixedExecutorTemplate executorTemplate() {
        return new FixedExecutorTemplate(executorProperties.getFixedPoolSize());
    }

    @Bean
    public ValidateTemplate validateTemplate() {
        return new ValidateTemplate();
    }
}
